



//
//  NProcessInstrucitonViewController.m
//  nncloud
//
//  Created by macfai on 2018/9/25.
//  Copyright © 2018年 youedata. All rights reserved.
//

#import "NProcessInstrucitonViewController.h"
#import "NFeedbackPopView.h"
#import "NConfirmPopView.h"
#import "NStarPopView.h"
#import "NFeedbackPop.h"
#import "NUsualProblemModel.h"
#import "NProblemDetailViewController.h"
@interface NProcessInstrucitonViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)UITableView *tableView;

@property (nonatomic,strong)NSMutableArray *dataArray;

@property (nonatomic,strong)NStarPopView *starview;

@property (nonatomic,strong)NConfirmPopView *confirmView;

@property (nonatomic,strong)NFeedbackPopView *feedPopView;

@end

@implementation NProcessInstrucitonViewController

#define cellIdentifier  @"sys"
-(UITableView *)tableView{
    
    if (!_tableView) {
        
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 0, ScreenWidth , ScreenHeight - 64) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 60.f;
        _tableView.backgroundColor = kBackgroundColor;
//        [_tableView registerNib:[UINib nibWithNibName:@"UITableViewCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.tableFooterView = [UIView new];
        //        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.dataArray = [NSMutableArray array];
    self.view.backgroundColor = kWhiteColor;
    [self.navigationItem setItemWithTitle:@"常见问题" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    
    [self.view addSubview:self.tableView];
    
    [self loadData];
    
//    [self addNavgationRightButtonWithFrame:CGRectMake(0, 0, 30, 30) title:@"" Image:nil selectedIMG:nil tartget:self action:@selector(tap)];
    // Do any additional setup after loading the view from its nib.
}

- (void)loadData{
    
    //后期逐渐添加参数目前不需要参数
//    NSDictionary
    [[NNRCNetRequest manager]getWithUrl:kCommonProblemListUrl params:nil success:^(id result) {
        YYLog(@"%@",result);
        WeakStament(ws);
        if ([[result objectForKey:@"code"] integerValue] == 0) {
            NSArray *arr = result[@"page"][@"records"];
            YYLog(@"%@",arr);
            for (NSDictionary *dict in arr) {
                NUsualProblemModel  *model = [NUsualProblemModel mj_objectWithKeyValues:dict];
                [ws.dataArray addObject:model];
            }
            [ws.tableView reloadData];
        }else{
            [AFToast showText:result[@"msg"]];
        }

    } failure:^(id failure) {
        
    }];
}

- (void)tap {
    NFeedbackPopView *po = [[[NSBundle mainBundle]loadNibNamed:@"NFeedbackPopView" owner:self options:nil]lastObject];
    po.popBlock = ^(NSString *text) {
        YYLog(@"%@",text);
    };
    [self.view addSubview:po];

}


- (void)click {
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NUsualProblemModel *model = self.dataArray[indexPath.row];
    NProblemDetailViewController *det = [NProblemDetailViewController new];
    det.hidesBottomBarWhenPushed = YES;
    det.content = model.questionCommonContent;
    [self.navigationController pushViewController:det animated:YES];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    NUsualProblemModel *mod = self.dataArray[indexPath.row];
    cell.textLabel.text = mod.questionCommonTitle;
    cell.selectionStyle = 0;
    return cell;
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [super touchesBegan:touches withEvent:event];

//    NFeedbackPopView *po = [[[NSBundle mainBundle]loadNibNamed:@"NFeedbackPopView" owner:self options:nil]lastObject];
//    po.popBlock = ^(NSString *text) {
//        YYLog(@"%@",text);
//    };
//    [self.view addSubview:po];
    
//    WeakStament(ws);
//    _confirmView = [NConfirmPopView new];
//    [_confirmView show];
//    _confirmView.buttonClick = ^(UIButton *sender) {
//        [ws click];
//    };
    
//    星星视图
//    _starview = [NStarPopView new];
//    [_starview show];
//    _starview.starBlcock = ^(NSInteger tag, NSInteger value) {
//        YYLog(@"%ld",value);
//    };
//    _starview.buttonClick = ^(UIButton *sender) {
//        [ws click];

}
    

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
